/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.dojotec.biblioteca.jsf.domain;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Alan Almeida
 */
@Entity
@Table(name = "reserva")
@NamedQueries({
    @NamedQuery(name = "Reserva.buscarTodos", query = "SELECT r FROM Reserva r"),
    @NamedQuery(name = "Reserva.buscarPorId", query = "SELECT r FROM Reserva r WHERE r.id = :id")
})
public class Reserva implements Serializable {
    @Id 
      @SequenceGenerator( name = "reserva_id", sequenceName = "reserva_seq", allocationSize = 1 )  
      @GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "reserva_id" )
      @Column( name = "id", nullable = false )
    private Long id;
    @Column(name = "data_reserva", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataReserva;
    @Column(name = "data_prevista", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataPrevista;
    @JoinColumn(name = "livro_id", referencedColumnName = "id")
    @ManyToOne
    private Livro livro;
    @JoinColumn(name = "usuario_id", referencedColumnName = "id")
    @ManyToOne
    private Usuario usuario;

    public Reserva() {
        
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getDataReserva() {
        return dataReserva;
    }

    public void setDataReserva(Date dataReserva) {
        this.dataReserva = dataReserva;
    }

    public Date getDataPrevista() {
        return dataPrevista;
    }

    public void setDataPrevista(Date dataPrevista) {
        this.dataPrevista = dataPrevista;
    }

    public Livro getLivro() {
        return livro;
    }

    public void setLivro(Livro livro) {
        this.livro = livro;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

}
